/**
 * Copyright 2018-2021 Streamlit Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// stylelint-disable at-rule-no-vendor-prefix, declaration-no-important, selector-no-qualifying-type, property-no-vendor-prefi
@import "variables";
@import "vendor/rfs.scss";

@function valid-radius($radius) {
  $return: ();
  @each $value in $radius {
    @if type-of($value) == number {
      $return: append($return, max($value, 0));
    } @else {
      $return: append($return, $value);
    }
  }
  @return $return;
}

@mixin border-radius($radius: $border-radius, $fallback-border-radius: false) {
  @if $enable-rounded {
    border-radius: valid-radius($radius);
  } @else if $fallback-border-radius != false {
    border-radius: $fallback-border-radius;
  }
}

// Remaining Reboot. Most have been ported to `globalStyles.ts`

// Body
html {
  @include font-size($font-size-base);
}

h1 {
  @include font-size(2.75rem);
}

h2 {
  @include font-size(2.25rem);
}

h3 {
  @include font-size(1.75rem);
}

h4 {
  @include font-size(1.5rem);
}

h5 {
  @include font-size(1.25rem);
}

h6 {
  @include font-size(1rem);
}

// Small
//
// Add the correct font size in all browsers

small {
  @include font-size($small-font-size);
}

// Sub and Sup
//
// Prevent sub and sup elements from affecting the line height in
// all browsers.

sub,
sup {
  @include font-size($sub-sup-font-size);
}

// Code

pre,
code,
kbd {
  @include font-size(1em); // Correct the odd em font sizing in all browsers.
}

pre {
  @include font-size($code-font-size);

  // Account for some code outputs that place code tags in pre tags
  code {
    @include font-size(inherit);
  }
}

code {
  @include font-size($code-font-size);
}

kbd {
  @include font-size($kbd-font-size);
  @include border-radius($border-radius-sm);

  kbd {
    @include font-size(1em);
  }
}

// Forms

input,
button,
select,
optgroup,
textarea {
  @include font-size(inherit);
}

// 1. Prevent a WebKit bug where (2) destroys native audio and video
//    controls in Android 4.
// 2. Opinionated: add "hand" cursor to non-disabled button elements.

button,
  [type="button"], // 1
  [type="reset"],
  [type="submit"] {
  @if $enable-button-pointers {
    &:not(:disabled) {
      cursor: pointer; // 2
    }
  }
}

legend {
  @include font-size($legend-font-size);
}
